package cn.com.twoke.application.game.mario.core.ecs.component.render.shape;


import cn.com.twoke.application.game.mario.core.ecs.component.render.RenderComponentHandler;
import cn.com.twoke.application.game.mario.core.ecs.entity.Entity;

import java.awt.*;
import java.awt.image.BufferedImage;

/**
 * 图形渲染
 */
public class ShapeRenderComponentHandler implements RenderComponentHandler<ShapeRenderComponent> {

    @Override
    public void handle(Entity entity, BufferedImage container, Graphics2D g, ShapeRenderComponent component) {
        g.setColor(component.getColor());
        if (component.isFill()) {
            g.fill(component.getShape());
        } else {
            g.draw(component.getShape());
        }
    }
}
